<!DOCTYPE html>
<html lang="en">
    <!-- title -->


    

<!-- keywords -->



<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="author" content="ZHAI">
    <meta name="renderer" content="webkit">
    <meta name="copyright" content="ZHAI">
    
        <meta name="keywords" content="hexo,hexo-theme,hexo-blog">
    
    <meta name="description" content="">
    <meta name="description" content="本文主要讲述通过MyBatis、JDBC等做大数据量数据插入的案例和结果。 # 30万条数据插入插入数据库验证 实体类、mapper和配置文件定义  User实体 mapper接口 mapper.xml文件 jdbc.properties sqlMapConfig.xml 不分批次直接梭哈 循环逐条插入 MyBatis实现插入30万条数据 JDBC实现插入30万条数据 总结  验证的数据库表结构如">
<meta property="og:type" content="article">
<meta property="og:title" content="13 秒插入 30 万条数据">
<meta property="og:url" content="https://zhai_zhihui.gitee.io/posts/688df240/index.html">
<meta property="og:site_name" content="Hexo">
<meta property="og:description" content="本文主要讲述通过MyBatis、JDBC等做大数据量数据插入的案例和结果。 # 30万条数据插入插入数据库验证 实体类、mapper和配置文件定义  User实体 mapper接口 mapper.xml文件 jdbc.properties sqlMapConfig.xml 不分批次直接梭哈 循环逐条插入 MyBatis实现插入30万条数据 JDBC实现插入30万条数据 总结  验证的数据库表结构如">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="https://zhai_zhihui.gitee.io/posts/688df240/640.png">
<meta property="og:image" content="https://zhai_zhihui.gitee.io/posts/688df240/640-1690880454566-3.gif">
<meta property="og:image" content="https://zhai_zhihui.gitee.io/posts/688df240/640-1690880456968-6.png">
<meta property="og:image" content="https://zhai_zhihui.gitee.io/posts/688df240/640-1690880458846-9.png">
<meta property="og:image" content="https://zhai_zhihui.gitee.io/posts/688df240/640-1690880466109-12.png">
<meta property="og:image" content="https://zhai_zhihui.gitee.io/posts/688df240/640-1690880505257-30.png">
<meta property="og:image" content="https://zhai_zhihui.gitee.io/posts/688df240/640-1690880469012-15.png">
<meta property="og:image" content="https://zhai_zhihui.gitee.io/posts/688df240/640-1690880470876-18.png">
<meta property="og:image" content="https://zhai_zhihui.gitee.io/posts/688df240/640-1690880472421-21.png">
<meta property="og:image" content="https://zhai_zhihui.gitee.io/posts/688df240/640-1690880476797-24.gif">
<meta property="og:image" content="https://zhai_zhihui.gitee.io/posts/688df240/640-1690880477978-27.png">
<meta property="article:published_time" content="2023-08-01T10:20:06.000Z">
<meta property="article:modified_time" content="2024-03-30T10:26:04.764Z">
<meta property="article:author" content="ZHAI">
<meta property="article:tag" content="java">
<meta property="article:tag" content="MyBatis">
<meta property="article:tag" content="JDBC">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://zhai_zhihui.gitee.io/posts/688df240/640.png">
    <meta http-equiv="Cache-control" content="no-cache">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="icon" href="/assets/favicon.ico">
    
    <title>13 秒插入 30 万条数据 · 翟 工作室</title>
    <!-- /*! loadCSS. [c]2017 Filament Group, Inc. MIT License */
/* This file is meant as a standalone workflow for
- testing support for link[rel=preload]
- enabling async CSS loading in browsers that do not support rel=preload
- applying rel preload css once loaded, whether supported or not.
*/ -->
<script>
    (function (w) {
        'use strict'
        // rel=preload support test
        if (!w.loadCSS) {
            w.loadCSS = function () {}
        }
        // define on the loadCSS obj
        var rp = (loadCSS.relpreload = {})
        // rel=preload feature support test
        // runs once and returns a function for compat purposes
        rp.support = (function () {
            var ret
            try {
                ret = w.document.createElement('link').relList.supports('preload')
            } catch (e) {
                ret = false
            }
            return function () {
                return ret
            }
        })()

        // if preload isn't supported, get an asynchronous load by using a non-matching media attribute
        // then change that media back to its intended value on load
        rp.bindMediaToggle = function (link) {
            // remember existing media attr for ultimate state, or default to 'all'
            var finalMedia = link.media || 'all'

            function enableStylesheet() {
                link.media = finalMedia
            }

            // bind load handlers to enable media
            if (link.addEventListener) {
                link.addEventListener('load', enableStylesheet)
            } else if (link.attachEvent) {
                link.attachEvent('onload', enableStylesheet)
            }

            // Set rel and non-applicable media type to start an async request
            // note: timeout allows this to happen async to let rendering continue in IE
            setTimeout(function () {
                link.rel = 'stylesheet'
                link.media = 'only x'
            })
            // also enable media after 3 seconds,
            // which will catch very old browsers (android 2.x, old firefox) that don't support onload on link
            setTimeout(enableStylesheet, 3000)
        }

        // loop through link elements in DOM
        rp.poly = function () {
            // double check this to prevent external calls from running
            if (rp.support()) {
                return
            }
            var links = w.document.getElementsByTagName('link')
            for (var i = 0; i < links.length; i++) {
                var link = links[i]
                // qualify links to those with rel=preload and as=style attrs
                if (
                    link.rel === 'preload' &&
                    link.getAttribute('as') === 'style' &&
                    !link.getAttribute('data-loadcss')
                ) {
                    // prevent rerunning on link
                    link.setAttribute('data-loadcss', true)
                    // bind listeners to toggle media back
                    rp.bindMediaToggle(link)
                }
            }
        }

        // if unsupported, run the polyfill
        if (!rp.support()) {
            // run once at least
            rp.poly()

            // rerun poly on an interval until onload
            var run = w.setInterval(rp.poly, 500)
            if (w.addEventListener) {
                w.addEventListener('load', function () {
                    rp.poly()
                    w.clearInterval(run)
                })
            } else if (w.attachEvent) {
                w.attachEvent('onload', function () {
                    rp.poly()
                    w.clearInterval(run)
                })
            }
        }

        // commonjs
        if (typeof exports !== 'undefined') {
            exports.loadCSS = loadCSS
        } else {
            w.loadCSS = loadCSS
        }
    })(typeof global !== 'undefined' ? global : this)
</script>

    <style type="text/css">
    @font-face {
        font-family: 'Oswald-Regular';
        src: url("/font/Oswald-Regular.ttf");
    }

    body {
        margin: 0;
    }

    header,
    footer,
    .back-top,
    .sidebar,
    .container,
    .site-intro-meta,
    .toc-wrapper {
        display: none;
    }

    .site-intro {
        position: relative;
        z-index: 3;
        width: 100%;
        /* height: 50vh; */
        overflow: hidden;
    }

    .site-intro-placeholder {
        position: absolute;
        z-index: -2;
        top: 0;
        left: 0;
        width: calc(100% + 300px);
        height: 100%;
        background: repeating-linear-gradient(-45deg, #444 0, #444 80px, #333 80px, #333 160px);
        background-position: center center;
        transform: translate3d(-226px, 0, 0);
        animation: gradient-move 2.5s ease-out 0s infinite;
    }

    @keyframes gradient-move {
        0% {
            transform: translate3d(-226px, 0, 0);
        }
        100% {
            transform: translate3d(0, 0, 0);
        }
    }
</style>

    <link rel="preload" href="/css/style.css?v=20211217" as="style" onload="this.onload=null;this.rel='stylesheet'">
    <link rel="preload" href="/css/dark.css?v=20211217" as="style">
    <link rel="stylesheet" href="/css/dark.css">
    <link rel="stylesheet" href="/css/mobile.css?v=20211217" media="(max-width: 960px)">
    <link rel="preload" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css" as="style" onload="this.onload=null;this.rel='stylesheet'">
    <link rel="preload" href="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js" as="script">
    <link rel="preload" href="/scripts/main.js?v=20211217" as="script">
    <link rel="preload" href="/scripts/dark.js?v=20211217" as="script">
    <link rel="preload" href="/font/Oswald-Regular.ttf" as="font" crossorigin>
    <link rel="preload" href="https://at.alicdn.com/t/font_327081_1dta1rlogw17zaor.woff" as="font" crossorigin>
    <!-- algolia -->
    
        <script>
            var hits = JSON.parse('{"per_page":10}')
            var labels = JSON.parse('{"input_placeholder":"Search for Posts","hits_empty":"我们没有找到任何搜索结果: ${query}","hits_stats":"找到${hits}条结果（用时${time} ms）"}')

            var algolia = {
                applicationID: '3GGJLFV539',
                apiKey: '12968f8a240b5852b40b42867fa50e60',
                indexName: 'hexo',
                hits: hits,
                labels: labels
            }
        </script>
    
    <!-- 百度统计  -->
    
    <!-- 谷歌统计  -->
    
<meta name="generator" content="Hexo 6.3.0"></head>

    <script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js"></script>
    <script type="text/javascript">
        if (typeof window.$ == undefined) {
            console.warn('jquery load from jsdelivr failed, will load local script')
            document.write('<script src="/lib/jquery.min.js" />')
        }
    </script>
    
        <body class="post-body">
    
        <!-- header -->
        <header class="header header-mobile">
    <!-- top read progress line -->
    <div class="header-element">
        <div class="read-progress"></div>
    </div>
    <!-- sidebar menu button -->
    <div class="header-element">
        
            <div class="header-sidebar-menu">
        
            
                <div style="padding-left: 1px;">&#xe775;</div>
            
        </div>
    </div>
    <!-- header actions -->
    <div class="header-actions">
        <!-- theme mode switch button -->
        <span class="header-theme-btn header-element">
            <i class="fas fa-adjust"></i>
        </span>
        <!-- back to home page text -->
        <span class="home-link header-element">
            <a href=/>翟.</a>
        </span>
    </div>
    <!-- toggle banner for post layout -->
    
        
            <div class="banner">
        
            <div class="blog-title header-element">
                <a href="/">翟.</a>
            </div>
            <div class="post-title header-element">
                <a href="#" class="post-name">13 秒插入 30 万条数据</a>
            </div>
        </div>
    
</header>

        <!-- fixed footer -->
        <footer class="footer-fixed">
    <!-- back to top button -->
    <div class="footer-fixed-element">
        
            <div class="back-top back-top-hidden">
        
        
            <div>&#xe639;</div>
        
        </div>
    </div>
</footer>

        <!-- wrapper -->
        <div class="wrapper">
            <div class="site-intro" style="







    height:50vh;

">
    
    <!-- 主页  -->
    
        
    <!-- 404页  -->
    
    <div class="site-intro-placeholder"></div>
    <div class="site-intro-img" style="background-image: url(/intro/post-bg.jpg)"></div>
    <div class="site-intro-meta">
        <!-- 标题  -->
        <h1 class="intro-title">
            <!-- 主页  -->
            
                13 秒插入 30 万条数据
            <!-- 404 -->
            
        </h1>
        <!-- 副标题 -->
        <p class="intro-subtitle">
            <!-- 主页副标题  -->
            
                
            <!-- 404 -->
            
        </p>
        <!-- 文章页 meta -->
        
            <div class="post-intros">
                <!-- 文章页标签  -->
                
                    <div class= post-intro-tags >
    
    
        <a class="post-tag" href="javascript:void(0);" data-tags="java">java</a>
    
        <a class="post-tag" href="javascript:void(0);" data-tags="MyBatis">MyBatis</a>
    
        <a class="post-tag" href="javascript:void(0);" data-tags="JDBC">JDBC</a>
    
</div>

                
                <!-- 文章字数统计 -->
                
                <div class="post-intro-meta">
                    <!-- 撰写日期 -->
                    <span class="iconfont-archer post-intro-calander">&#xe676;</span>
                    <span class="post-intro-time">2023/08/01</span>
                    <!-- busuanzi -->
                    
                        <span id="busuanzi_container_page_pv" class="busuanzi-pv">
                            <span class="iconfont-archer post-intro-busuanzi">&#xe602;</span>
                            <span id="busuanzi_value_page_pv"></span>
                        </span>
                    
                    <!-- 文章分享 -->
                    <span class="share-wrapper">
                        <span class="iconfont-archer share-icon">&#xe71d;</span>
                        <span class="share-text">Share</span>
                        <ul class="share-list">
                            <li class="iconfont-archer share-qr" data-type="qr">&#xe75b;
                                <div class="share-qrcode"></div>
                            </li>
                            <li class="iconfont-archer" data-type="weibo">&#xe619;</li>
                            <li class="iconfont-archer" data-type="qzone">&#xe62e;</li>
                            <li class="iconfont-archer" data-type="twitter">&#xe634;</li>
                            <li class="iconfont-archer" data-type="facebook">&#xe67a;</li>
                        </ul>
                    </span>
                </div>
            </div>
        
    </div>
</div>

            <script>
  // get user agent
  function getBrowserVersions() {
    var u = window.navigator.userAgent
    return {
      userAgent: u,
      trident: u.indexOf('Trident') > -1, //IE内核
      presto: u.indexOf('Presto') > -1, //opera内核
      webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
      gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核
      mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
      ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
      android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或者uc浏览器
      iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1, //是否为iPhone或者安卓QQ浏览器
      iPad: u.indexOf('iPad') > -1, //是否为iPad
      webApp: u.indexOf('Safari') == -1, //是否为web应用程序，没有头部与底部
      weixin: u.indexOf('MicroMessenger') == -1, //是否为微信浏览器
      uc: u.indexOf('UCBrowser') > -1, //是否为android下的UC浏览器
    }
  }
  var browser = {
    versions: getBrowserVersions(),
  }
  console.log('userAgent: ' + browser.versions.userAgent)

  // callback
  function fontLoaded() {
    console.log('font loaded')
    if (document.getElementsByClassName('site-intro-meta')) {
      document
        .getElementsByClassName('intro-title')[0]
        .classList.add('intro-fade-in')
      document
        .getElementsByClassName('intro-subtitle')[0]
        .classList.add('intro-fade-in')
      var postIntros = document.getElementsByClassName('post-intros')[0]
      if (postIntros) {
        postIntros.classList.add('post-fade-in')
      }
    }
  }

  // UC不支持跨域，所以直接显示
  function asyncCb() {
    if (browser.versions.uc) {
      console.log('UCBrowser')
      fontLoaded()
    } else {
      WebFont.load({
        custom: {
          families: ['Oswald-Regular'],
        },
        loading: function () {
          // 所有字体开始加载
          // console.log('font loading');
        },
        active: function () {
          // 所有字体已渲染
          fontLoaded()
        },
        inactive: function () {
          // 字体预加载失败，无效字体或浏览器不支持加载
          console.log('inactive: timeout')
          fontLoaded()
        },
        timeout: 5000, // Set the timeout to two seconds
      })
    }
  }

  function asyncErr() {
    console.warn('script load from CDN failed, will load local script')
  }

  // load webfont-loader async, and add callback function
  function async(u, cb, err) {
    var d = document,
      t = 'script',
      o = d.createElement(t),
      s = d.getElementsByTagName(t)[0]
    o.src = u
    if (cb) {
      o.addEventListener(
        'load',
        function (e) {
          cb(null, e)
        },
        false
      )
    }
    if (err) {
      o.addEventListener(
        'error',
        function (e) {
          err(null, e)
        },
        false
      )
    }
    s.parentNode.insertBefore(o, s)
  }

  var asyncLoadWithFallBack = function (arr, success, reject) {
    var currReject = function () {
      reject()
      arr.shift()
      if (arr.length) async(arr[0], success, currReject)
    }

    async(arr[0], success, currReject)
  }

  asyncLoadWithFallBack(
    [
      'https://cdn.jsdelivr.net/npm/webfontloader@1.6.28/webfontloader.min.js',
      'https://cdn.bootcss.com/webfont/1.6.28/webfontloader.js',
      "/lib/webfontloader.min.js",
    ],
    asyncCb,
    asyncErr
  )
</script>

            <img class="loading" src="/assets/loading.svg" style="display: block; margin: 6rem auto 0 auto; width: 6rem; height: 6rem;" />
            <div class="container container-unloaded">
                <main class="main post-page">
    <article class="article-entry">
        <p>本文主要讲述通过MyBatis、JDBC等做大数据量数据插入的案例和结果。</p>
<p><strong># 30万条数据插入插入数据库验证</strong></p>
<p>实体类、mapper和配置文件定义</p>
<ul>
<li>User实体</li>
<li>mapper接口</li>
<li>mapper.xml文件</li>
<li>jdbc.properties</li>
<li>sqlMapConfig.xml</li>
<li>不分批次直接梭哈</li>
<li>循环逐条插入</li>
<li>MyBatis实现插入30万条数据</li>
<li>JDBC实现插入30万条数据</li>
<li>总结</li>
</ul>
<p>验证的数据库表结构如下：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">CREATE TABLE `t_user` (</span><br><span class="line">  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT &#x27;用户id&#x27;,</span><br><span class="line">  `username` varchar(64) DEFAULT NULL COMMENT &#x27;用户名称&#x27;,</span><br><span class="line">  `age` int(4) DEFAULT NULL COMMENT &#x27;年龄&#x27;,</span><br><span class="line">  PRIMARY KEY (`id`)</span><br><span class="line">) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=&#x27;用户信息表&#x27;;</span><br></pre></td></tr></table></figure>

<p>话不多说，开整！</p>
<p><strong># 实体类、mapper和配置文件定义</strong></p>
<p>User实体</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">/**</span><br><span class="line"> * &lt;p&gt;用户实体&lt;/p&gt;</span><br><span class="line"> *</span><br><span class="line"> * @Author zjq</span><br><span class="line"> * @Date 2021/8/3</span><br><span class="line"> */</span><br><span class="line">@Data</span><br><span class="line">public class User &#123;</span><br><span class="line">    private int id;</span><br><span class="line">    private String username;</span><br><span class="line">    private int age;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>mapper接口</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">public interface UserMapper &#123;</span><br><span class="line">    /**</span><br><span class="line">     * 批量插入用户</span><br><span class="line">     * @param userList</span><br><span class="line">     */</span><br><span class="line">    void batchInsertUser(@Param(&quot;list&quot;) List&lt;User&gt; userList);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>mapper.xml文件</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">&lt;!-- 批量插入用户信息 --&gt;</span><br><span class="line">&lt;insert id=&quot;batchInsertUser&quot; parameterType=&quot;java.util.List&quot;&gt;</span><br><span class="line">    insert into t_user(username,age) values</span><br><span class="line">    &lt;foreach collection=&quot;list&quot; item=&quot;item&quot; index=&quot;index&quot; separator=&quot;,&quot;&gt;</span><br><span class="line">        (</span><br><span class="line">        #&#123;item.username&#125;,</span><br><span class="line">        #&#123;item.age&#125;</span><br><span class="line">        )</span><br><span class="line">    &lt;/foreach&gt;</span><br><span class="line">&lt;/insert&gt;</span><br></pre></td></tr></table></figure>

<p>jdbc.properties</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">jdbc.driver=com.mysql.jdbc.Driver</span><br><span class="line">jdbc.url=jdbc:mysql://localhost:3306/test</span><br><span class="line">jdbc.username=root</span><br><span class="line">jdbc.password=root</span><br></pre></td></tr></table></figure>

<p>sqlMapConfig.xml</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;</span><br><span class="line">&lt;!DOCTYPE configuration PUBLIC &quot;-//mybatis.org//DTD Config 3.0//EN&quot; &quot;http://mybatis.org/dtd/mybatis-3-config.dtd&quot;&gt;</span><br><span class="line">&lt;configuration&gt;</span><br><span class="line">    &lt;!--通过properties标签加载外部properties文件--&gt;</span><br><span class="line">    &lt;properties resource=&quot;jdbc.properties&quot;&gt;&lt;/properties&gt;</span><br><span class="line">    &lt;!--自定义别名--&gt;</span><br><span class="line">    &lt;typeAliases&gt;</span><br><span class="line">        &lt;typeAlias type=&quot;com.zjq.domain.User&quot; alias=&quot;user&quot;&gt;&lt;/typeAlias&gt;</span><br><span class="line">    &lt;/typeAliases&gt;</span><br><span class="line">    &lt;!--数据源环境--&gt;</span><br><span class="line">    &lt;environments default=&quot;developement&quot;&gt;</span><br><span class="line">        &lt;environment id=&quot;developement&quot;&gt;</span><br><span class="line">            &lt;transactionManager type=&quot;JDBC&quot;&gt;&lt;/transactionManager&gt;</span><br><span class="line">            &lt;dataSource type=&quot;POOLED&quot;&gt;</span><br><span class="line">                &lt;property name=&quot;driver&quot; value=&quot;$&#123;jdbc.driver&#125;&quot;/&gt;</span><br><span class="line">                &lt;property name=&quot;url&quot; value=&quot;$&#123;jdbc.url&#125;&quot;/&gt;</span><br><span class="line">                &lt;property name=&quot;username&quot; value=&quot;$&#123;jdbc.username&#125;&quot;/&gt;</span><br><span class="line">                &lt;property name=&quot;password&quot; value=&quot;$&#123;jdbc.password&#125;&quot;/&gt;</span><br><span class="line">            &lt;/dataSource&gt;</span><br><span class="line">        &lt;/environment&gt;</span><br><span class="line">    &lt;/environments&gt;</span><br><span class="line">    &lt;!--加载映射文件--&gt;</span><br><span class="line">    &lt;mappers&gt;</span><br><span class="line">        &lt;mapper resource=&quot;com/zjq/mapper/UserMapper.xml&quot;&gt;&lt;/mapper&gt;</span><br><span class="line">    &lt;/mappers&gt;</span><br><span class="line">&lt;/configuration&gt;</span><br></pre></td></tr></table></figure>

<p><strong>不分批次直接梭哈</strong></p>
<p>MyBatis直接一次性批量插入30万条，代码如下：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line">@Test</span><br><span class="line">public void testBatchInsertUser() throws IOException &#123;</span><br><span class="line">    InputStream resourceAsStream =</span><br><span class="line">            Resources.getResourceAsStream(&quot;sqlMapConfig.xml&quot;);</span><br><span class="line">    SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(resourceAsStream);</span><br><span class="line">    SqlSession session = sqlSessionFactory.openSession();</span><br><span class="line">    System.out.println(&quot;===== 开始插入数据 =====&quot;);</span><br><span class="line">    long startTime = System.currentTimeMillis();</span><br><span class="line">    try &#123;</span><br><span class="line">        List&lt;User&gt; userList = new ArrayList&lt;&gt;();</span><br><span class="line">        for (int i = 1; i &lt;= 300000; i++) &#123;</span><br><span class="line">            User user = new User();</span><br><span class="line">            user.setId(i);</span><br><span class="line">            user.setUsername(&quot;共饮一杯无 &quot; + i);</span><br><span class="line">            user.setAge((int) (Math.random() * 100));</span><br><span class="line">            userList.add(user);</span><br><span class="line">        &#125;</span><br><span class="line">        session.insert(&quot;batchInsertUser&quot;, userList); // 最后插入剩余的数据</span><br><span class="line">        session.commit();</span><br><span class="line">        long spendTime = System.currentTimeMillis()-startTime;</span><br><span class="line">        System.out.println(&quot;成功插入 30 万条数据,耗时：&quot;+spendTime+&quot;毫秒&quot;);</span><br><span class="line">    &#125; finally &#123;</span><br><span class="line">        session.close();</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>可以看到控制台输出：</p>
<blockquote>
<p>Cause: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (27759038 &gt;yun 4194304). You can change this value on the server by setting the max_allowed_packet’ variable.</p>
</blockquote>
<p>超出最大数据包限制了，可以通过调整max_allowed_packet限制来提高可以传输的内容，不过由于30万条数据超出太多，这个不可取，梭哈看来是不行了 😅😅😅</p>
<p>既然梭哈不行那我们就一条一条循环着插入行不行呢</p>
<p><strong>循环逐条插入</strong></p>
<p>mapper接口和mapper文件中新增单个用户新增的内容如下:</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">/**</span><br><span class="line"> * 新增单个用户</span><br><span class="line"> * @param user</span><br><span class="line"> */</span><br><span class="line">void insertUser(User user);</span><br><span class="line">&lt;!-- 新增用户信息 --&gt;</span><br><span class="line">&lt;insert id=&quot;insertUser&quot; parameterType=&quot;user&quot;&gt;</span><br><span class="line">    insert into t_user(username,age) values</span><br><span class="line">        (</span><br><span class="line">        #&#123;username&#125;,</span><br><span class="line">        #&#123;age&#125;</span><br><span class="line">        )</span><br><span class="line">&lt;/insert&gt;</span><br></pre></td></tr></table></figure>

<p>调整执行代码如下：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line">@Test</span><br><span class="line">public void testCirculateInsertUser() throws IOException &#123;</span><br><span class="line">    InputStream resourceAsStream =</span><br><span class="line">            Resources.getResourceAsStream(&quot;sqlMapConfig.xml&quot;);</span><br><span class="line">    SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(resourceAsStream);</span><br><span class="line">    SqlSession session = sqlSessionFactory.openSession();</span><br><span class="line">    System.out.println(&quot;===== 开始插入数据 =====&quot;);</span><br><span class="line">    long startTime = System.currentTimeMillis();</span><br><span class="line">    try &#123;</span><br><span class="line">        for (int i = 1; i &lt;= 300000; i++) &#123;</span><br><span class="line">            User user = new User();</span><br><span class="line">            user.setId(i);</span><br><span class="line">            user.setUsername(&quot;共饮一杯无 &quot; + i);</span><br><span class="line">            user.setAge((int) (Math.random() * 100));</span><br><span class="line">            // 一条一条新增</span><br><span class="line">            session.insert(&quot;insertUser&quot;, user);</span><br><span class="line">            session.commit();</span><br><span class="line">        &#125;</span><br><span class="line">        long spendTime = System.currentTimeMillis()-startTime;</span><br><span class="line">        System.out.println(&quot;成功插入 30 万条数据,耗时：&quot;+spendTime+&quot;毫秒&quot;);</span><br><span class="line">    &#125; finally &#123;</span><br><span class="line">        session.close();</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>执行后可以发现磁盘IO占比飙升，一直处于高位。</p>
<p><img src="/posts/688df240/640.png" alt="图片"></p>
<p>等啊等等啊等，好久还没执行完</p>
<p><img src="/posts/688df240/640-1690880454566-3.gif" alt="图片"></p>
<p>先不管他了太慢了先搞其他的，等会再来看看结果吧。</p>
<p>控制台输出如下：</p>
<p><img src="/posts/688df240/640-1690880456968-6.png" alt="图片"></p>
<p>总共执行了14909367毫秒，换算出来是4小时八分钟。太慢了。。</p>
<p><img src="/posts/688df240/640-1690880458846-9.png" alt="图片"></p>
<p>👇👇👇还是优化下之前的批处理方案吧</p>
<p><strong># MyBatis实现插入30万条数据</strong></p>
<p>先清理表数据，然后优化批处理执行插入：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">-- 清空用户表</span><br><span class="line">TRUNCATE table  t_user;</span><br></pre></td></tr></table></figure>

<p>以下是通过 MyBatis 实现 30 万条数据插入代码实现：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br></pre></td><td class="code"><pre><span class="line">/**</span><br><span class="line"> * 分批次批量插入</span><br><span class="line"> * @throws IOException</span><br><span class="line"> */</span><br><span class="line">@Test</span><br><span class="line">public void testBatchInsertUser() throws IOException &#123;</span><br><span class="line">    InputStream resourceAsStream =</span><br><span class="line">            Resources.getResourceAsStream(&quot;sqlMapConfig.xml&quot;);</span><br><span class="line">    SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(resourceAsStream);</span><br><span class="line">    SqlSession session = sqlSessionFactory.openSession();</span><br><span class="line">    System.out.println(&quot;===== 开始插入数据 =====&quot;);</span><br><span class="line">    long startTime = System.currentTimeMillis();</span><br><span class="line">    int waitTime = 10;</span><br><span class="line">    try &#123;</span><br><span class="line">        List&lt;User&gt; userList = new ArrayList&lt;&gt;();</span><br><span class="line">        for (int i = 1; i &lt;= 300000; i++) &#123;</span><br><span class="line">            User user = new User();</span><br><span class="line">            user.setId(i);</span><br><span class="line">            user.setUsername(&quot;共饮一杯无 &quot; + i);</span><br><span class="line">            user.setAge((int) (Math.random() * 100));</span><br><span class="line">            userList.add(user);</span><br><span class="line">            if (i % 1000 == 0) &#123;</span><br><span class="line">                session.insert(&quot;batchInsertUser&quot;, userList);</span><br><span class="line">                // 每 1000 条数据提交一次事务</span><br><span class="line">                session.commit();</span><br><span class="line">                userList.clear();</span><br><span class="line">                // 等待一段时间</span><br><span class="line">                Thread.sleep(waitTime * 1000);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        // 最后插入剩余的数据</span><br><span class="line">        if(!CollectionUtils.isEmpty(userList)) &#123;</span><br><span class="line">            session.insert(&quot;batchInsertUser&quot;, userList);</span><br><span class="line">            session.commit();</span><br><span class="line">        &#125;</span><br><span class="line">        long spendTime = System.currentTimeMillis()-startTime;</span><br><span class="line">        System.out.println(&quot;成功插入 30 万条数据,耗时：&quot;+spendTime+&quot;毫秒&quot;);</span><br><span class="line">    &#125; catch (Exception e) &#123;</span><br><span class="line">        e.printStackTrace();</span><br><span class="line">    &#125; finally &#123;</span><br><span class="line">        session.close();</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>使用了 MyBatis 的批处理操作，将每 1000 条数据放在一个批次中插入，能够较为有效地提高插入速度。同时请注意在循环插入时要带有合适的等待时间和批处理大小，以防止出现内存占用过高等问题。此外，还需要在配置文件中设置合理的连接池和数据库的参数，以获得更好的性能。</p>
<p><img src="/posts/688df240/640-1690880466109-12.png" alt="图片"></p>
<p>在上面的示例中，我们每插入1000行数据就进行一次批处理提交，并等待10秒钟。这有助于控制内存占用，并确保插入操作平稳进行。</p>
<p><img src="/posts/688df240/640-1690880505257-30.png" alt="图片"></p>
<p>五十分钟执行完毕，时间主要用在了等待上。</p>
<p>如果低谷时期执行，CPU和磁盘性能又足够的情况下，直接批处理不等待执行：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br></pre></td><td class="code"><pre><span class="line">/**</span><br><span class="line"> * 分批次批量插入</span><br><span class="line"> * @throws IOException</span><br><span class="line"> */</span><br><span class="line">@Test</span><br><span class="line">public void testBatchInsertUser() throws IOException &#123;</span><br><span class="line">    InputStream resourceAsStream =</span><br><span class="line">            Resources.getResourceAsStream(&quot;sqlMapConfig.xml&quot;);</span><br><span class="line">    SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(resourceAsStream);</span><br><span class="line">    SqlSession session = sqlSessionFactory.openSession();</span><br><span class="line">    System.out.println(&quot;===== 开始插入数据 =====&quot;);</span><br><span class="line">    long startTime = System.currentTimeMillis();</span><br><span class="line">    int waitTime = 10;</span><br><span class="line">    try &#123;</span><br><span class="line">        List&lt;User&gt; userList = new ArrayList&lt;&gt;();</span><br><span class="line">        for (int i = 1; i &lt;= 300000; i++) &#123;</span><br><span class="line">            User user = new User();</span><br><span class="line">            user.setId(i);</span><br><span class="line">            user.setUsername(&quot;共饮一杯无 &quot; + i);</span><br><span class="line">            user.setAge((int) (Math.random() * 100));</span><br><span class="line">            userList.add(user);</span><br><span class="line">            if (i % 1000 == 0) &#123;</span><br><span class="line">                session.insert(&quot;batchInsertUser&quot;, userList);</span><br><span class="line">                // 每 1000 条数据提交一次事务</span><br><span class="line">                session.commit();</span><br><span class="line">                userList.clear();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        // 最后插入剩余的数据</span><br><span class="line">        if(!CollectionUtils.isEmpty(userList)) &#123;</span><br><span class="line">            session.insert(&quot;batchInsertUser&quot;, userList);</span><br><span class="line">            session.commit();</span><br><span class="line">        &#125;</span><br><span class="line">        long spendTime = System.currentTimeMillis()-startTime;</span><br><span class="line">        System.out.println(&quot;成功插入 30 万条数据,耗时：&quot;+spendTime+&quot;毫秒&quot;);</span><br><span class="line">    &#125; catch (Exception e) &#123;</span><br><span class="line">        e.printStackTrace();</span><br><span class="line">    &#125; finally &#123;</span><br><span class="line">        session.close();</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>则24秒可以完成数据插入操作：</p>
<p><img src="/posts/688df240/640-1690880469012-15.png" alt="图片"></p>
<p><img src="/posts/688df240/640-1690880470876-18.png" alt="图片"></p>
<p>可以看到短时CPU和磁盘占用会飙高。</p>
<p>把批处理的量再调大一些调到5000，在执行：</p>
<p><img src="/posts/688df240/640-1690880472421-21.png" alt="图片"></p>
<p>13秒插入成功30万条，直接芜湖起飞🛫🛫🛫</p>
<p><strong># JDBC实现插入30万条数据</strong></p>
<p>JDBC循环插入的话跟上面的mybatis逐条插入类似，不再赘述。</p>
<p>以下是 Java 使用 JDBC 批处理实现 30 万条数据插入的示例代码。请注意，该代码仅提供思路，具体实现需根据实际情况进行修改。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br></pre></td><td class="code"><pre><span class="line">/**</span><br><span class="line"> * JDBC分批次批量插入</span><br><span class="line"> * @throws IOException</span><br><span class="line"> */</span><br><span class="line">@Test</span><br><span class="line">public void testJDBCBatchInsertUser() throws IOException &#123;</span><br><span class="line">    Connection connection = null;</span><br><span class="line">    PreparedStatement preparedStatement = null;</span><br><span class="line">    String databaseURL = &quot;jdbc:mysql://localhost:3306/test&quot;;</span><br><span class="line">    String user = &quot;root&quot;;</span><br><span class="line">    String password = &quot;root&quot;;</span><br><span class="line">    try &#123;</span><br><span class="line">        connection = DriverManager.getConnection(databaseURL, user, password);</span><br><span class="line">        // 关闭自动提交事务，改为手动提交</span><br><span class="line">        connection.setAutoCommit(false);</span><br><span class="line">        System.out.println(&quot;===== 开始插入数据 =====&quot;);</span><br><span class="line">        long startTime = System.currentTimeMillis();</span><br><span class="line">        String sqlInsert = &quot;INSERT INTO t_user ( username, age) VALUES ( ?, ?)&quot;;</span><br><span class="line">        preparedStatement = connection.prepareStatement(sqlInsert);</span><br><span class="line">        Random random = new Random();</span><br><span class="line">        for (int i = 1; i &lt;= 300000; i++) &#123;</span><br><span class="line">            preparedStatement.setString(1, &quot;共饮一杯无 &quot; + i);</span><br><span class="line">            preparedStatement.setInt(2, random.nextInt(100));</span><br><span class="line">            // 添加到批处理中</span><br><span class="line">            preparedStatement.addBatch();</span><br><span class="line">            if (i % 1000 == 0) &#123;</span><br><span class="line">                // 每1000条数据提交一次</span><br><span class="line">                preparedStatement.executeBatch();</span><br><span class="line">                connection.commit();</span><br><span class="line">                System.out.println(&quot;成功插入第 &quot;+ i+&quot; 条数据&quot;);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        // 处理剩余的数据</span><br><span class="line">        preparedStatement.executeBatch();</span><br><span class="line">        connection.commit();</span><br><span class="line">        long spendTime = System.currentTimeMillis()-startTime;</span><br><span class="line">        System.out.println(&quot;成功插入 30 万条数据,耗时：&quot;+spendTime+&quot;毫秒&quot;);</span><br><span class="line">    &#125; catch (SQLException e) &#123;</span><br><span class="line">        System.out.println(&quot;Error: &quot; + e.getMessage());</span><br><span class="line">    &#125; finally &#123;</span><br><span class="line">        if (preparedStatement != null) &#123;</span><br><span class="line">            try &#123;</span><br><span class="line">                preparedStatement.close();</span><br><span class="line">            &#125; catch (SQLException e) &#123;</span><br><span class="line">                e.printStackTrace();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        if (connection != null) &#123;</span><br><span class="line">            try &#123;</span><br><span class="line">                connection.close();</span><br><span class="line">            &#125; catch (SQLException e) &#123;</span><br><span class="line">                e.printStackTrace();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p><img src="/posts/688df240/640-1690880476797-24.gif" alt="图片"></p>
<p><img src="/posts/688df240/640-1690880477978-27.png" alt="图片"></p>
<p>上述示例代码中，我们通过 JDBC 连接 MySQL 数据库，并执行批处理操作插入数据。具体实现步骤如下：</p>
<ul>
<li>获取数据库连接。</li>
<li>创建 Statement 对象。</li>
<li>定义 SQL 语句，使用 PreparedStatement 对象预编译 SQL 语句并设置参数。</li>
<li>执行批处理操作。</li>
<li>处理剩余的数据。</li>
<li>关闭 Statement 和 Connection 对象。</li>
</ul>
<p>使用setAutoCommit(false) 来禁止自动提交事务，然后在每次批量插入之后手动提交事务。每次插入数据时都新建一个 PreparedStatement 对象以避免状态不一致问题。在插入数据的循环中，每 10000 条数据就执行一次 executeBatch() 插入数据。</p>
<p>另外，需要根据实际情况优化连接池和数据库的相关配置，以防止连接超时等问题。</p>
<p><strong># 总结</strong></p>
<p>实现高效的大量数据插入需要结合以下优化策略（建议综合使用）：</p>
<p>1.批处理：批量提交SQL语句可以降低网络传输和处理开销，减少与数据库交互的次数。在Java中可以使用Statement或者PreparedStatement的addBatch()方法来添加多个SQL语句，然后一次性执行executeBatch()方法提交批处理的SQL语句。</p>
<ul>
<li>在循环插入时带有适当的等待时间和批处理大小，从而避免内存占用过高等问题：</li>
<li>设置适当的批处理大小：批处理大小指在一次插入操作中插入多少行数据。如果批处理大小太小，插入操作的频率将很高，而如果批处理大小太大，可能会导致内存占用过高。通常，建议将批处理大小设置为1000-5000行，这将减少插入操作的频率并降低内存占用。</li>
<li>采用适当的等待时间：等待时间指在批处理操作之间等待的时间量。等待时间过短可能会导致内存占用过高，而等待时间过长则可能会延迟插入操作的速度。通常，建议将等待时间设置为几秒钟到几十秒钟之间，这将使操作变得平滑且避免出现内存占用过高等问题。</li>
<li>可以考虑使用一些内存优化的技巧，例如使用内存数据库或使用游标方式插入数据，以减少内存占用。</li>
<li>总的来说，选择适当的批处理大小和等待时间可以帮助您平稳地进行插入操作，避免出现内存占用过高等问题。</li>
</ul>
<p>2.索引: 在大量数据插入前暂时去掉索引，最后再打上，这样可以大大减少写入时候的更新索引的时间。</p>
<p>3.数据库连接池：使用数据库连接池可以减少数据库连接建立和关闭的开销，提高性能。在没有使用数据库连接池的情况，记得在finally中关闭相关连接。</p>
<p>数据库参数调整：增加MySQL数据库缓冲区大小、配置高性能的磁盘和I&#x2F;O等。</p>
<blockquote>
<p>来源：blog.csdn.net&#x2F;qq_35427589&#x2F;article&#x2F;details&#x2F;129665307</p>
</blockquote>

    </article>
    <!-- license -->
    
        <div class="license-wrapper">
            <p>Author：<a href="https://zhai_zhihui.gitee.io">ZHAI</a>
            <p>Link：<a href="https://zhai_zhihui.gitee.io/posts/688df240/">https://zhai_zhihui.gitee.io/posts/688df240/</a>
            <p>Publish date：<a href="https://zhai_zhihui.gitee.io/posts/688df240/">August 1st 2023, 6:20:06 pm</a>
            <p>Update date：<a href="https://zhai_zhihui.gitee.io/posts/688df240/">March 30th 2024, 6:26:04 pm</a>
            <p>License：本文采用<a rel="license noopener" target="_blank" href="http://creativecommons.org/licenses/by-nc/4.0/">知识共享署名-非商业性使用 4.0 国际许可协议</a>进行许可</p>
        </div>
    
    <!-- paginator -->
    <ul class="post-paginator">
        <li class="next">
            
                <div class="nextSlogan">Next Post</div>
                <a href="/posts/c66d13f4/" title="Linux使用curl发起post请求的常用方式">
                    <div class="nextTitle">Linux使用curl发起post请求的常用方式</div>
                </a>
            
        </li>
        <li class="previous">
            
                <div class="prevSlogan">Previous Post</div>
                <a href="/posts/7624ea2a/" title="品诺王版卤味">
                    <div class="prevTitle">品诺王版卤味</div>
                </a>
            
        </li>
    </ul>
    <!-- comment -->
    
        <div class="post-comment">
            <!-- 来必力 City 版安装代码 -->


            

            

            

            <!-- utteranc评论 -->


            <!-- partial('_partial/comment/changyan') -->
            <!--PC版-->


            
            
    <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
    <script src='//unpkg.com/valine/dist/Valine.min.js'></script>
    <div id="comment"></div>
    <script>
        new Valine({
            el: '#comment',
            notify:false,
            verify:false,
            appId: "03H2Ay0YFmCc3Rk59ctLWuOK-gzGzoHsz",
            appKey: "kjtH05mMZzVhDksfF47nTRyQ",
            placeholder: "",
            path:window.location.pathname,
            avatar:'mm'
        });
    </script>


            

        </div>
    
    <!-- timeliness note -->
    <!-- idea from: https://hexo.fluid-dev.com/posts/hexo-injector/#%E6%96%87%E7%AB%A0%E6%97%B6%E6%95%88%E6%80%A7%E6%8F%90%E7%A4%BA -->
    
    <!-- Mathjax -->
    
</main>

                <!-- profile -->
                
            </div>
            <footer class="footer footer-unloaded">
    <!-- social  -->
    
        <div class="social">
            
    
        
            
                <a href="mailto:1828038025@qq.com" class="iconfont-archer email" title=email ></a>
            
        
    
        
            
                <a href="//gitee.com/zhai_zhihui" class="iconfont-archer github" target="_blank" title=github></a>
            
        
    
        
            
                <span class="iconfont-archer wechat" title=wechat>
                    
                    <img class="profile-qr" src="/assets/example_qr.png" />
                </span>
            
        
    
        
            
                <span class="iconfont-archer qq" title=qq>
                    
                    <img class="profile-qr" src="/assets/example_qr2.jpg" />
                </span>
            
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    


        </div>
    
    <!-- powered by Hexo  -->
    <div class="copyright">
        <span id="hexo-power">Powered by <a href="https://hexo.io/" target="_blank">Hexo</a></span><span class="iconfont-archer power">&#xe635;</span><span id="theme-info">theme <a href="https://github.com/fi3ework/hexo-theme-archer" target="_blank">Archer</a></span>
    </div>
    <!-- website approve for Chinese user -->
    
    <!-- 不蒜子  -->
    
        <div class="busuanzi-container">
            
             
                <span id="busuanzi_container_site_pv">PV: <span id="busuanzi_value_site_pv"></span> :)</span>
            
        </div>
    	
</footer>

        </div>
        <!-- toc -->
        
            <div class="toc-wrapper toc-wrapper-loding" style=







    top:50vh;

>
                <div class="toc-catalog">
                    <span class="iconfont-archer catalog-icon">&#xe613;</span><span>CATALOG</span>
                </div>
                
            </div>
        
        <!-- sidebar -->
        <div class="sidebar sidebar-hide">
    <ul class="sidebar-tabs sidebar-tabs-active-0">
        <li class="sidebar-tab-archives"><span class="iconfont-archer">&#xe67d;</span><span class="tab-name">Archive</span></li>
        <li class="sidebar-tab-tags"><span class="iconfont-archer">&#xe61b;</span><span class="tab-name">Tag</span></li>
        <li class="sidebar-tab-categories"><span class="iconfont-archer">&#xe666;</span><span class="tab-name">Cate</span></li>
    </ul>
    <div class="sidebar-content sidebar-content-show-archive">
        <div class="sidebar-panel-archives">
    <!-- 在 ejs 中将 archive 按照时间排序 -->
    
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
    
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
    
    
    
    
    <div class="total-and-search">
        <div class="total-archive">
        Total : 51
        </div>
        <!-- search  -->
        
            <div class="site-search site-search-loading popup-trigger">
                <span class="iconfont-archer search-icon">&#xe627;</span>
            </div>
        
    </div>
    
    <div class="post-archive">
    
        
            
            
            <div class="archive-year"> 2024 </div>
            <ul class="year-list">
            
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/27</span>
            <a class="archive-post-title" href="/posts/f61093aa/">白斌-谈判技巧</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/24</span>
            <a class="archive-post-title" href="/posts/e4931d34/">5个ChatGPT搞钱成功案例</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/22</span>
            <a class="archive-post-title" href="/posts/c34d6d3f/">pua</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/21</span>
            <a class="archive-post-title" href="/posts/cd2752f2/">如何在竞争对手强大繁多的困境突出重围？且看Insta360如何做到</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/20</span>
            <a class="archive-post-title" href="/posts/47fc87c9/">互联网公司架构</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/15</span>
            <a class="archive-post-title" href="/posts/881f29f/">Hexo加密</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/15</span>
            <a class="archive-post-title" href="/posts/2e543a56/">刻意练习</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/15</span>
            <a class="archive-post-title" href="/posts/50749798/">关于思维、强势文化、马克思主义、唯心主义、唯物主义的思考及对话</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/15</span>
            <a class="archive-post-title" href="/posts/d68051b9/">强势文化与弱势文化</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/12</span>
            <a class="archive-post-title" href="/posts/e8831614/">思维</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/12</span>
            <a class="archive-post-title" href="/posts/9a21e95f/">潜意识编辑</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/12</span>
            <a class="archive-post-title" href="/posts/3ad44071/">知行合一</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">03/30</span>
            <a class="archive-post-title" href="/posts/f1a9ae87/">字节跳动CEO张一鸣2014年采访</a>
        </li>
    
        
            
            
                
                </ul>
            
            <div class="archive-year"> 2023 </div>
            <ul class="year-list">
            
        
        <li class="archive-post-item">
            <span class="archive-post-date">10/18</span>
            <a class="archive-post-title" href="/posts/c42bcc42/">实体集合分页类</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">09/05</span>
            <a class="archive-post-title" href="/posts/91c508e3/">多线程实现异步</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">09/05</span>
            <a class="archive-post-title" href="/posts/cab7a692/">获取客户端外网ip</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">09/01</span>
            <a class="archive-post-title" href="/posts/56cc41e2/">朱厘米师傅的绉纱馄饨教程</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">08/31</span>
            <a class="archive-post-title" href="/posts/c66d13f4/">Linux使用curl发起post请求的常用方式</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">08/01</span>
            <a class="archive-post-title" href="/posts/688df240/">13 秒插入 30 万条数据</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">07/04</span>
            <a class="archive-post-title" href="/posts/7624ea2a/">品诺王版卤味</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">05/30</span>
            <a class="archive-post-title" href="/posts/342f571b/">分库分表Sharding-JDBC</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">05/17</span>
            <a class="archive-post-title" href="/posts/74214fa/">OpenVPN同时连多个vpn</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">05/17</span>
            <a class="archive-post-title" href="/posts/439c6055/">家人们谁懂啊这也太可爱了吧！</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">05/15</span>
            <a class="archive-post-title" href="/posts/c2569e69/">实体类集合转另一个实体类集合</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/27</span>
            <a class="archive-post-title" href="/posts/a5a91285/">hexo-abbrlink和hexo-asset-image插件冲突</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/27</span>
            <a class="archive-post-title" href="/posts/8b7ba7da/">Hexo+Algolia实现搜索</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/26</span>
            <a class="archive-post-title" href="/posts/ba39e0a3/">hexo+valine博客的评论功能</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/26</span>
            <a class="archive-post-title" href="/posts/28c0f33e/">JAVA计算大量数据接口怎么做</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/26</span>
            <a class="archive-post-title" href="/posts/e5c137a2/">判断字符串是否中英文类</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/26</span>
            <a class="archive-post-title" href="/posts/2a7156f8/">DM8自动生成代码</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/21</span>
            <a class="archive-post-title" href="/posts/353f598a/">Hexo-零基础搭建个人博客(详解)</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/21</span>
            <a class="archive-post-title" href="/posts/e5bae2ba/">Hexo搭配Typora图片问题</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/21</span>
            <a class="archive-post-title" href="/posts/e55b8c2b/">java什么叫事务，事务有什么用</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/21</span>
            <a class="archive-post-title" href="/posts/7deee04a/">java如何根据IP获取当前区域天气信息详解</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/21</span>
            <a class="archive-post-title" href="/posts/3904c7be/">java计算判断时间是否大于15分钟</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/21</span>
            <a class="archive-post-title" href="/posts/a6669b86/">linux部署jar包</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/21</span>
            <a class="archive-post-title" href="/posts/dd843aa7/">mybatis判空提高效率</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/21</span>
            <a class="archive-post-title" href="/posts/ea6a3de/">springboot项目启动时执行代码</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/21</span>
            <a class="archive-post-title" href="/posts/30e6d251/">vscode插件好用的插件</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/21</span>
            <a class="archive-post-title" href="/posts/24409baf/">使用IDEA根据wsdl生成WebServices客户端代码</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/21</span>
            <a class="archive-post-title" href="/posts/918792c0/">判断集合是否有重复元素</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/21</span>
            <a class="archive-post-title" href="/posts/6c39f264/">取差集工具类（高效率）</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/21</span>
            <a class="archive-post-title" href="/posts/4c3f96ac/">客户端外网ip工具类</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/21</span>
            <a class="archive-post-title" href="/posts/ea92058c/">使用流式数据处理检查list中是否有重复的元素并返回重复元素</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/21</span>
            <a class="archive-post-title" href="/posts/90c8aa59/">查询字符串出现位置工具类</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/21</span>
            <a class="archive-post-title" href="/posts/d6f28e22/">根据外网IP获取用户所在城市工具类</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/21</span>
            <a class="archive-post-title" href="/posts/79be3dc6/">用SpringBoot连接redis并处理数据</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/21</span>
            <a class="archive-post-title" href="/posts/2fa39047/">雪花算法生成ID工具类</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">04/21</span>
            <a class="archive-post-title" href="/posts/1eedc1b4/">markdown引入图片、音频、视频</a>
        </li>
    
        
            
            
                
                </ul>
            
            <div class="archive-year"> 2022 </div>
            <ul class="year-list">
            
        
        <li class="archive-post-item">
            <span class="archive-post-date">01/07</span>
            <a class="archive-post-title" href="/posts/4e2a03f/">java最便捷的word导出方法（POI-TL）</a>
        </li>
    
        
        <li class="archive-post-item">
            <span class="archive-post-date">01/07</span>
            <a class="archive-post-title" href="/posts/77673b17/">图片转 BASE64 编码</a>
        </li>
    
    </div>
</div>

        <div class="sidebar-panel-tags">
    <div class="sidebar-tags-name">
        
            <span class="sidebar-tag-name" data-tags="java">
                <span class="iconfont-archer">&#xe606;</span>
                java
            </span>
        
            <span class="sidebar-tag-name" data-tags="MyBatis">
                <span class="iconfont-archer">&#xe606;</span>
                MyBatis
            </span>
        
            <span class="sidebar-tag-name" data-tags="JDBC">
                <span class="iconfont-archer">&#xe606;</span>
                JDBC
            </span>
        
            <span class="sidebar-tag-name" data-tags="自动生成">
                <span class="iconfont-archer">&#xe606;</span>
                自动生成
            </span>
        
            <span class="sidebar-tag-name" data-tags="IDEA">
                <span class="iconfont-archer">&#xe606;</span>
                IDEA
            </span>
        
            <span class="sidebar-tag-name" data-tags="DM8">
                <span class="iconfont-archer">&#xe606;</span>
                DM8
            </span>
        
            <span class="sidebar-tag-name" data-tags="Node.js">
                <span class="iconfont-archer">&#xe606;</span>
                Node.js
            </span>
        
            <span class="sidebar-tag-name" data-tags="redis">
                <span class="iconfont-archer">&#xe606;</span>
                redis
            </span>
        
            <span class="sidebar-tag-name" data-tags="若依">
                <span class="iconfont-archer">&#xe606;</span>
                若依
            </span>
        
            <span class="sidebar-tag-name" data-tags="搭建">
                <span class="iconfont-archer">&#xe606;</span>
                搭建
            </span>
        
            <span class="sidebar-tag-name" data-tags="插件">
                <span class="iconfont-archer">&#xe606;</span>
                插件
            </span>
        
            <span class="sidebar-tag-name" data-tags="hexo-blog-encrypt">
                <span class="iconfont-archer">&#xe606;</span>
                hexo-blog-encrypt
            </span>
        
            <span class="sidebar-tag-name" data-tags="hexo-asset-image">
                <span class="iconfont-archer">&#xe606;</span>
                hexo-asset-image
            </span>
        
            <span class="sidebar-tag-name" data-tags="优化">
                <span class="iconfont-archer">&#xe606;</span>
                优化
            </span>
        
            <span class="sidebar-tag-name" data-tags="vpn">
                <span class="iconfont-archer">&#xe606;</span>
                vpn
            </span>
        
            <span class="sidebar-tag-name" data-tags="事务">
                <span class="iconfont-archer">&#xe606;</span>
                事务
            </span>
        
            <span class="sidebar-tag-name" data-tags="mysql">
                <span class="iconfont-archer">&#xe606;</span>
                mysql
            </span>
        
            <span class="sidebar-tag-name" data-tags="工具类">
                <span class="iconfont-archer">&#xe606;</span>
                工具类
            </span>
        
            <span class="sidebar-tag-name" data-tags="天气">
                <span class="iconfont-archer">&#xe606;</span>
                天气
            </span>
        
            <span class="sidebar-tag-name" data-tags="时间">
                <span class="iconfont-archer">&#xe606;</span>
                时间
            </span>
        
            <span class="sidebar-tag-name" data-tags="jar">
                <span class="iconfont-archer">&#xe606;</span>
                jar
            </span>
        
            <span class="sidebar-tag-name" data-tags="导出">
                <span class="iconfont-archer">&#xe606;</span>
                导出
            </span>
        
            <span class="sidebar-tag-name" data-tags="POI">
                <span class="iconfont-archer">&#xe606;</span>
                POI
            </span>
        
            <span class="sidebar-tag-name" data-tags="WORD">
                <span class="iconfont-archer">&#xe606;</span>
                WORD
            </span>
        
            <span class="sidebar-tag-name" data-tags="SpringBoot">
                <span class="iconfont-archer">&#xe606;</span>
                SpringBoot
            </span>
        
            <span class="sidebar-tag-name" data-tags="vscode">
                <span class="iconfont-archer">&#xe606;</span>
                vscode
            </span>
        
            <span class="sidebar-tag-name" data-tags="wsdl">
                <span class="iconfont-archer">&#xe606;</span>
                wsdl
            </span>
        
            <span class="sidebar-tag-name" data-tags="思维系统">
                <span class="iconfont-archer">&#xe606;</span>
                思维系统
            </span>
        
            <span class="sidebar-tag-name" data-tags="马克思主义">
                <span class="iconfont-archer">&#xe606;</span>
                马克思主义
            </span>
        
            <span class="sidebar-tag-name" data-tags="强势文化">
                <span class="iconfont-archer">&#xe606;</span>
                强势文化
            </span>
        
            <span class="sidebar-tag-name" data-tags="唯心主义">
                <span class="iconfont-archer">&#xe606;</span>
                唯心主义
            </span>
        
            <span class="sidebar-tag-name" data-tags="唯物主义">
                <span class="iconfont-archer">&#xe606;</span>
                唯物主义
            </span>
        
            <span class="sidebar-tag-name" data-tags="集合">
                <span class="iconfont-archer">&#xe606;</span>
                集合
            </span>
        
            <span class="sidebar-tag-name" data-tags="肉">
                <span class="iconfont-archer">&#xe606;</span>
                肉
            </span>
        
            <span class="sidebar-tag-name" data-tags="卤味">
                <span class="iconfont-archer">&#xe606;</span>
                卤味
            </span>
        
            <span class="sidebar-tag-name" data-tags="年夜饭">
                <span class="iconfont-archer">&#xe606;</span>
                年夜饭
            </span>
        
            <span class="sidebar-tag-name" data-tags="base64">
                <span class="iconfont-archer">&#xe606;</span>
                base64
            </span>
        
            <span class="sidebar-tag-name" data-tags="ip">
                <span class="iconfont-archer">&#xe606;</span>
                ip
            </span>
        
            <span class="sidebar-tag-name" data-tags="弱势文化">
                <span class="iconfont-archer">&#xe606;</span>
                弱势文化
            </span>
        
            <span class="sidebar-tag-name" data-tags="认知与实践">
                <span class="iconfont-archer">&#xe606;</span>
                认知与实践
            </span>
        
            <span class="sidebar-tag-name" data-tags="地理位置">
                <span class="iconfont-archer">&#xe606;</span>
                地理位置
            </span>
        
            <span class="sidebar-tag-name" data-tags="算法">
                <span class="iconfont-archer">&#xe606;</span>
                算法
            </span>
        
            <span class="sidebar-tag-name" data-tags="互联网">
                <span class="iconfont-archer">&#xe606;</span>
                互联网
            </span>
        
            <span class="sidebar-tag-name" data-tags="站在巨人肩膀上">
                <span class="iconfont-archer">&#xe606;</span>
                站在巨人肩膀上
            </span>
        
            <span class="sidebar-tag-name" data-tags="突围">
                <span class="iconfont-archer">&#xe606;</span>
                突围
            </span>
        
            <span class="sidebar-tag-name" data-tags="创新">
                <span class="iconfont-archer">&#xe606;</span>
                创新
            </span>
        
            <span class="sidebar-tag-name" data-tags="创业">
                <span class="iconfont-archer">&#xe606;</span>
                创业
            </span>
        
            <span class="sidebar-tag-name" data-tags="工具">
                <span class="iconfont-archer">&#xe606;</span>
                工具
            </span>
        
            <span class="sidebar-tag-name" data-tags="搞钱">
                <span class="iconfont-archer">&#xe606;</span>
                搞钱
            </span>
        
            <span class="sidebar-tag-name" data-tags="沟通">
                <span class="iconfont-archer">&#xe606;</span>
                沟通
            </span>
        
            <span class="sidebar-tag-name" data-tags="谈判">
                <span class="iconfont-archer">&#xe606;</span>
                谈判
            </span>
        
    </div>
    <div class="iconfont-archer sidebar-tags-empty">&#xe678;</div>
    <div class="tag-load-fail" style="display: none; color: #ccc; font-size: 0.6rem;">
        缺失模块，请参考主题文档进行安装配置：https://github.com/fi3ework/hexo-theme-archer#%E5%AE%89%E8%A3%85%E4%B8%BB%E9%A2%98
    </div> 
    <div class="sidebar-tags-list"></div>
</div>

        <div class="sidebar-panel-categories">
    <div class="sidebar-categories-name">
    
        <span class="sidebar-category-name" data-categories="代码">
            <span class="iconfont-archer">&#xe60a;</span>
            代码
        </span>
    
        <span class="sidebar-category-name" data-categories="hexo">
            <span class="iconfont-archer">&#xe60a;</span>
            hexo
        </span>
    
        <span class="sidebar-category-name" data-categories="linux">
            <span class="iconfont-archer">&#xe60a;</span>
            linux
        </span>
    
        <span class="sidebar-category-name" data-categories="工具">
            <span class="iconfont-archer">&#xe60a;</span>
            工具
        </span>
    
        <span class="sidebar-category-name" data-categories="markdown">
            <span class="iconfont-archer">&#xe60a;</span>
            markdown
        </span>
    
        <span class="sidebar-category-name" data-categories="哲学">
            <span class="iconfont-archer">&#xe60a;</span>
            哲学
        </span>
    
        <span class="sidebar-category-name" data-categories="美食">
            <span class="iconfont-archer">&#xe60a;</span>
            美食
        </span>
    
        <span class="sidebar-category-name" data-categories="小猫咪">
            <span class="iconfont-archer">&#xe60a;</span>
            小猫咪
        </span>
    
        <span class="sidebar-category-name" data-categories="互联网公司">
            <span class="iconfont-archer">&#xe60a;</span>
            互联网公司
        </span>
    
        <span class="sidebar-category-name" data-categories="ChatGPT">
            <span class="iconfont-archer">&#xe60a;</span>
            ChatGPT
        </span>
    
        <span class="sidebar-category-name" data-categories="人际交往">
            <span class="iconfont-archer">&#xe60a;</span>
            人际交往
        </span>
    
        <span class="sidebar-category-name" data-categories="沟通">
            <span class="iconfont-archer">&#xe60a;</span>
            沟通
        </span>
    
    </div>
    <div class="iconfont-archer sidebar-categories-empty">&#xe678;</div>
    <div class="sidebar-categories-list"></div>
</div>

    </div>
</div>

        <!-- site-meta -->
        <script>
    var siteMetaRoot = "/"
    if (siteMetaRoot === "undefined") {
        siteMetaRoot = '/'
    }
    var siteMeta = {
        url: "https://zhai_zhihui.gitee.io",
        root: siteMetaRoot,
        author: "ZHAI"
    }
</script>

        <!-- import experimental options here -->
        <!-- Custom Font -->


        <!-- main func -->
        <script src="/scripts/main.js?v=20211217"></script>
        <!-- dark mode -->
        <script src="/scripts/dark.js?v=20211217"></script>
        <!-- fancybox -->
        <script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js" defer></script>
        <!-- algolia -->
        
            <div class="site-search site-search-loading">
    <div class="algolia-popup popup">
        <div class="algolia-search">
            <div class="algolia-search-input-icon">
                <i class="fa fa-search"></i>
            </div>
            <div class="algolia-search-input" id="algolia-search-input"></div>
            <div class="popup-btn-close">
                <i class="iconfont-archer">&#xe609;</i>
            </div>
        </div>

        <div class="algolia-results">
            <div id="algolia-stats" class="algolia-stats"></div>
            <div id="algolia-hits"></div>
            <div id="algolia-pagination" class="algolia-pagination"></div>
        </div>
    </div>
</div>

            <script src="/scripts/search.js?v=20211217" defer></script>
        
        <!-- busuanzi -->
        
            <script src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" async></script>
        
        <!-- CNZZ -->
        
        <!-- async load share.js -->
        
            <script src="/scripts/share.js?v=20211217" async></script>
        
        <!-- mermaid -->
        
    </body>
</html>
